﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace power
{
    
    public partial class scrible : PhoneApplicationPage
    {
        public scrible()
        {
            InitializeComponent();
            SetBoundary();

        }

        Stroke NewStroke;

        private void MyIP_MouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            
            MyIP.CaptureMouse();
            StylusPointCollection MyStylusPointCollection = new StylusPointCollection();
            MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP));
            NewStroke = new Stroke(MyStylusPointCollection);
            MyIP.Strokes.Add(NewStroke);
        }

        private void MyIP_MouseMove(object sender, MouseEventArgs e)
        {
            if (NewStroke != null)
                NewStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(MyIP));
        }

        private void MyIP_LostMouseCapture(object sender, MouseEventArgs e)
        {
            NewStroke = null;
        }

        private void SetBoundary()
        {
            RectangleGeometry MyRectangleGeometry = new RectangleGeometry();
            MyRectangleGeometry.Rect = new Rect(0, 0, MyIP.ActualWidth, MyIP.ActualHeight);
            MyIP.Clip = MyRectangleGeometry;
        }

        private void Path_Tap(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/createSlide.xaml", UriKind.Relative));
        }

        private void Path_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (MyIP.Strokes != null && MyIP.Strokes.Count > 0)
            {

                MyIP.Strokes.RemoveAt(MyIP.Strokes.Count - 1);
            }
        }
    }
}